package br.com.fatecpg.mamaeconomiza;

import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;

public class DetailsProductActivity extends Activity {

	TextView textProduto;
	TextView textPreco;
	TextView TextFabricante;
	TextView textDetalhes;
	
	private String name, price, maker, description, address, shop;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_details_product);
		
		ActionBar actionBar = getActionBar();
		actionBar.setDisplayHomeAsUpEnabled(true);

		Intent product = getIntent();
		name = product.getStringExtra("NAME");
		price = product.getStringExtra("PRICE");
		maker = product.getStringExtra("MAKER");
		description = product.getStringExtra("DESCRIPTION");
		address = product.getStringExtra("ADDRESS");
		shop = product.getStringExtra("SHOP");
		 
		 Log.d("PRODUCT", name + " / " + price + " / " + maker + " / " + description + " / " + address + " / " + shop);
		
		textProduto = (TextView) findViewById(R.id.textProd);
		textPreco = (TextView) findViewById(R.id.textPrice);
		TextFabricante = (TextView) findViewById(R.id.textMaker);
		textDetalhes = (TextView) findViewById(R.id.textDesc);
		
		textProduto.setText(name);
		textPreco.setText("R$ " + price);
		TextFabricante.setText(maker);
		textDetalhes.setText(description);

	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.details_product, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		
		Intent intent;
		int id = item.getItemId();
		
		if (id == R.id.action_place) {
			intent = new Intent(getBaseContext(), MapsActivity.class);
			intent.putExtra("ADDRESS", address);
			intent.putExtra("SHOP", shop);
			startActivity(intent);
			
		}
		return super.onOptionsItemSelected(item);
	}
}
